function [e] = exp_range(name,mu, sigm, lb,ub) 
%{
d = (ub-lb)./10000;
X = zeros(length(lb),10001);
for i=1:length(lb)
   if d(i)>0
       X(i,:) = lb(i):d(i):ub(i);
   else
       X(i,:) = lb(i);
   end;
end;
if name=='Lognormal'
    Y = lognpdf(X,mu,sigm)./(cdf('Lognormal',ub,mu,sigm) - cdf('Lognormal',lb,mu,sigm)); %normalized pdf
    e = sum(d.*X.*Y);
else
    di('Undefined for specified distrbution');
    e = NaN;
end;

end
%}

for i = 1:length(lb)    
    d = (ub(i)-lb(i))/2000; % SG if the bounds are too large and beyond the mass of the distribution, then d imght be too coarse 

    if d>0
       X= lb(i):d:ub(i);
    else
       X= lb(i)*ones(1,1001);
    end;

    if strcmp(name,'Lognormal')
        Y = lognpdf(X,mu(i),sigm(i))./(cdf('Lognormal',ub(i),mu(i),sigm(i)) - cdf('Lognormal',lb(i),mu(i),sigm(i))); %normalized pdf
        temp = sum(d.*X.*Y);
    elseif strcmp(name,'Normal')
        Y = pdf('Normal',X,mu(i),sigm(i))./(cdf('Normal',ub(i),mu(i),sigm(i)) - cdf('Normal',lb(i),mu(i),sigm(i))); %normalized pdf
        temp = sum(d.*X.*Y);
    else
        di('Undefined for specified distrbution');
        temp = NaN;
    end;
    e(i) = temp;
end;